<script setup>
import { defineProps, defineEmits, ref } from 'vue';

const props = defineProps({
  isVisible: {
    type: Boolean,
    default: false
  }
});

const emit = defineEmits(['update:searchQuery', 'create-post']);

const searchQuery = ref('');

const updateSearch = (e) => {
  searchQuery.value = e.target.value;
  emit('update:searchQuery', searchQuery.value);
};

const openCreatePostModal = () => {
  emit('create-post');
};
</script>

<template>
  <div class="forum-actions" :class="{ 'animate': isVisible }">
    <div class="search-wrapper">
      <input 
        type="text" 
        :value="searchQuery"
        @input="updateSearch"
        placeholder="Search topics..." 
        class="search-input"
      >
      <div class="search-icon">🔍</div>
    </div>
    
    <button class="create-post-btn" @click="openCreatePostModal">
      <span class="btn-icon">✏️</span>
      <span class="btn-text">Create New Topic</span>
    </button>
  </div>
</template>

<style scoped>
/* 操作区域样式 */
.forum-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease 0.2s;
}

.forum-actions.animate {
  opacity: 1;
  transform: translateY(0);
}

.search-wrapper {
  position: relative;
  width: 360px;
}

.search-input {
  width: 100%;
  height: 50px;
  padding: 0 20px 0 45px;
  border-radius: 25px;
  border: 1px solid #e0e0e0;
  background-color: #f8f8f8;
  font-size: 1rem;
  transition: all 0.3s;
}

.search-input:focus {
  border-color: #00c389;
  box-shadow: 0 0 0 3px rgba(0, 195, 137, 0.1);
  background-color: #ffffff;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.create-post-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  padding: 0 25px;
  background-color: #00c389;
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0, 195, 137, 0.15);
}

.create-post-btn:hover {
  background-color: #00a873;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 195, 137, 0.2);
}

.btn-icon {
  margin-right: 8px;
}

@media (max-width: 768px) {
  .forum-actions {
    flex-direction: column;
    gap: 20px;
  }
  
  .search-wrapper {
    width: 100%;
  }
  
  .create-post-btn {
    width: 100%;
  }
}
</style> 